local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({
		"git",
		"clone",
		"--filter=blob:none",
		"https://github.com/folke/lazy.nvim.git",
		"--branch=stable", -- latest stable release
		lazypath,
	})
end
vim.opt.rtp:prepend(lazypath)

local plugins = {
	"folke/tokyonight.nvim",    -- 主题
	"nvim-lualine/lualine.nvim", -- 状态栏
	{
		"nvim-tree/nvim-tree.lua",
		cmd = { "NvimTreeToggle", "NvimTreeOpen", "NvimTreeFocus" },
		keys = {
			{ "<leader>-", "<cmd>NvimTreeToggle<cr>", desc = "Explorer" }
		}
	},
	{ "nvim-tree/nvim-web-devicons", lazy = true },          -- 文档树图标
	"christoomey/vim-tmux-navigator",                        -- 用ctl-hjkl来定位窗口
	{
		"nvim-treesitter/nvim-treesitter",                     -- 语法高亮
		run = ':TSUpdate',                                     -- 确保在安装后更新
		config = function()
			require 'nvim-treesitter.install'.compilers = { "gcc" } -- 只使用gcc作为编译器
		end,
	},
	-- "p00f/nvim-ts-rainbow",
	-- 配合treesitter，不同括号颜色区分
	{
		{ "mason-org/mason.nvim",           cmd = "Mason" },
		{ "mason-org/mason-lspconfig.nvim", laz = true }, -- 这个相当于mason.nvim和lspconfig的桥梁
		"neovim/nvim-lspconfig"
	},
	-- 自动补全
	"hrsh7th/nvim-cmp",
	"hrsh7th/cmp-nvim-lsp",
	'hrsh7th/cmp-cmdline', -- 命令行补全支持

	"L3MON4D3/LuaSnip",   -- snippets引擎，不装这个自动补全会出问题
	"saadparwaiz1/cmp_luasnip",
	"rafamadriz/friendly-snippets",
	"hrsh7th/cmp-path",       -- 文件路径

	"numToStr/Comment.nvim",  -- gcc和gc注释
	"windwp/nvim-autopairs",  -- 自动补全括号

	"akinsho/bufferline.nvim", -- buffer分割线
	{
		'nvim-telescope/telescope.nvim',
		tag = '0.1.8',
		dependencies = { 'nvim-lua/plenary.nvim' }
	},

	{
		'akinsho/toggleterm.nvim',
		cmd = "Toggleterm",
		version = "*",
		config = true
	}, -- terminal插件
	{ "ellisonleao/glow.nvim",       config = true, cmd = "Glow" },
	-- 增强lsp功能
	{
		'nvimdev/lspsaga.nvim',
		dependencies = {
			'nvim-treesitter/nvim-treesitter', -- optional
			'nvim-tree/nvim-web-devicons',  -- optional
		}
	},
	{
		'nvimdev/dashboard-nvim',
		event = 'VimEnter',
		dependencies = { { 'nvim-tree/nvim-web-devicons' } }
	},
	{
		"lukas-reineke/indent-blankline.nvim",
		main = "ibl",
	},
	{
		"folke/noice.nvim",
		event = "VeryLazy",
		opts = {
		},
		dependencies = {
			"MunifTanjim/nui.nvim",
			"rcarriga/nvim-notify",
		}
	},
	{
		'nvim-treesitter/nvim-treesitter-context',
		dependencies = { 'nvim-treesitter/nvim-treesitter' },
	},
	{ 'tamton-aquib/duck.nvim', },
	{ "catppuccin/nvim",        name = "catppuccin", priority = 1000 },
	{
		'barrett-ruth/live-server.nvim',
		build = 'pnpm add -g live-server',
		cmd = { 'LiveServerStart', 'LiveServerStop' },
		config = true
	},
	{
		'norcalli/nvim-colorizer.lua'
	},
	-- rainbow
	'HiPhish/rainbow-delimiters.nvim',
	-- git signs
	'lewis6991/gitsigns.nvim',
	{
		"mfussenegger/nvim-jdtls",
		ft = { "java" },
		dependencies = {
			"neovim/nvim-lspconfig",
		},
	},
	---@type LazySpec
	{
		"mikavilpas/yazi.nvim",
		event = "VeryLazy",
		dependencies = {
			{ "nvim-lua/plenary.nvim", lazy = true },
		},
		keys = {
			{ "<leader>e",  mode = { "n", "v" },    "<cmd>Yazi<cr>",                                           desc = "Open yazi at the current file" },
			{ "<leader>cw", "<cmd>Yazi cwd<cr>",    desc = "Open the file manager in nvim's working directory" },
			{ "<c-up>",     "<cmd>Yazi toggle<cr>", desc = "Resume the last yazi session" },
		},
		opts = {
			open_for_directories = false,
			keymaps = {
				show_help = "<f1>",
			},
		},
		init = function()
			vim.g.loaded_netrwPlugin = 1
		end,
	},
	{
		'MeanderingProgrammer/render-markdown.nvim',
		dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-mini/mini.nvim' },       -- if you use the mini.nvim suite
		dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons
		---@module 'render-markdown'
		---@type render.md.UserConfig
		opts = {},
	},

	"sphamba/smear-cursor.nvim",

	{
		"kndndrj/nvim-dbee",
		dependencies = {
			"MunifTanjim/nui.nvim",
		},
		build = function()
			-- 强制用 go 安装
			require("dbee").install("go")
		end,
		config = function()
			require("dbee").setup( --[[optional config]])
		end,
	}
}
local opts = {} -- 注意要定义这个变量

require("lazy").setup(plugins, opts)
